﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    用户管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script src="<%: Url.Content("~/Scripts/userJs/jquery.uiTableFilter.js") %>" type="text/javascript"></script>
    <script src="<%: Url.Content("~/Scripts/userJs/member.js") %>" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#tblMain tr").find("td:eq(1)").click(function () {
                if (!$(".customerInfoShowbox").is(':animated')) {
                    var alias = $.trim($(this).text());
                    var r = new Date();
                    $.ajax({
                        url: "../../Member/getCustomerDetailInfo?r=" + r.getMilliseconds(),
                        type: "GET",
                        data: { "alias": alias },
                        dataType: "json",
                        success: function (data) {
                            $("fieldset", $("li#userDetailInfo")).remove();
                            switch (data.status) {
                                case "2":
                                    if (data.baseInfo) {
                                        var $field_baseInfo = "<fieldset><legend>基本信息</legend><p>Alias：" + data.baseInfo.userName + "</p><p>Email：" + data.baseInfo.email + "</p><p>系统角色：" + data.baseInfo.role + "</p><p>所在小组：" + data.baseInfo.team + "</p><p>职位：" + data.baseInfo.position + "</p></fieldset>";
                                        $("li#userDetailInfo").append($field_baseInfo);
                                    }
                                    if (data.assets) {
                                        $.each(data.assets, function (i, item) {
                                            var $field_asset = "<fieldset><legend>资产信息</legend><p>资产ID：" + item.assetID + "</p><p>型号：" + item.type + "</p><p>S_n：" + item.Sn + "</p><p>描述：" + item.description + "</p><p>日期：" + item.date + "</p></fieldset>";
                                            $("li#userDetailInfo").append($field_asset);
                                        });
                                    }
                                    if (data.networks) {
                                        $.each(data.networks, function (i, item) {
                                            var $field_network = "<fieldset><legend>网络信息</legend><p>MAC：" + item.MAC + "</p><p>资产ID：" + item.assetID + "</p><p>网络状态：" + item.status + "</p><p>最近更新日期：" + item.date + "</p></fieldset>";
                                            $("li#userDetailInfo").append($field_network);
                                        });
                                    }
                                    if (data.account) {
                                        var $field_account = "<fieldset><legend>bell账号信息</legend><p>账号ID：" + data.account.accountID + "</p><p>员工编号：" + data.account.empNo + "</p><p>账号状态：" + data.account.status + "</p><p>域名：" + data.account.domain + "</p><p>最近更新日期：" + data.account.date + "</p></fieldset>";
                                        $("li#userDetailInfo").append($field_account);
                                    }
                                    if (data.card) {
                                        var $field_card = "<fieldset><legend>bell磁卡信息</legend><p>磁卡号：" + data.card.cardNo + "</p><p>磁卡状态：" + data.card.status + "</p><p>最近更新日期：" + data.card.date + "</p></fieldset>";
                                        $("li#userDetailInfo").append($field_card);
                                    }
                                    break;
                                default:
                                    alert("该用户不存在");
                                    break;
                            }
                        }
                    });
                    $(".customerInfoShowbox").animate({ left: '-=750px' }, 500);
                }
            }).css("cursor", "pointer");
            $("#backToMainTable").click(function () {
                if (!$(".customerInfoShowbox").is(':animated')) {
                    $(".customerInfoShowbox").animate({ left: '+=750px' }, 500);
                }
            }).css("cursor", "pointer");
        })
    </script>
    <div class="dashboard">
        <input type="button" id="btnInsert" value="添加员工" class="addUpdateMember" />
        <input type="button" id="btnDelete" value="删除选中员工信息" />
    </div>
    <div class="content">
        <div class="customerInfoShowbox">
            <ul>
                <li>
                    <table id="tblMain">
                        <thead>
                            <tr>
                                <th>
                                    <input id="cbkAll" type="checkbox" />
                                </th>
                                <th scope="col">
                                    员工编号
                                </th>
                                <th scope="col">
                                    所属团队
                                </th>
                                <th scope="col">
                                    职位
                                </th>
                                <th scope="col">
                                    邮箱
                                </th>
                                <th scope="col">
                                    入职日期
                                </th>
                                <th scope="col">
                                    系统角色
                                </th>
                                <th scope="col">
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <%foreach (var a in Model)
                              {%>
                            <tr>
                                <td class="row">
                                    <input id="<%=a.UserName %>" type="checkbox" />
                                </td>
                                <td class="row">
                                    <%=a.UserName%>
                                </td>
                                <td class="row">
                                    <%=  a.Team %>
                                </td>
                                <td class="row">
                                    <%= a.Position%>
                                </td>
                                <td class="row">
                                    <%=a.Email%>
                                </td>
                                <td class="row">
                                    <%=a.startDate == null ? "" : a.startDate.ToShortDateString()%>
                                </td>
                                <td class="row">
                                    <%=a.Role%>
                                </td>
                                <td class="row">
                                    <input class="addUpdateMember" id="btnUpdate" type="button" name="update" value="修改" />
                                </td>
                            </tr>
                            <%} %>
                        </tbody>
                    </table>
                </li>
                <li id="userDetailInfo"><span id="backToMainTable">返回</span> </li>
            </ul>
        </div>
    </div>
    <div id="greybackground">
    </div>
    <div class="popupWindow">
        <p class="closePopup" >
            </p>
        <h2 class="titlePopup">
            添加新的员工</h2>
        <table class="tbladd">  
            <tr>
                <td>
                    员工Alias：
                </td>
                <td>
                    <input id="alias" type="text" name="alias" /><span> *</span>
                </td>
                <td>
                    系统权限：
                </td>
                <td>
                    <select id="selRoles">
                        <option value="admin">管理员</option>
                        <option value="member">普通员工</option>
                    </select>
                    <span>*</span>
                </td>
            </tr>
            <tr>
                <td>
                    所属团队：
                </td>
                <td>
                    <select id="selTeam">
                    </select>
                    <input id="iptTeam" class="none" type="text" />
                    <span>*</span>
                </td>
                <td>
                    职位：
                </td>
                <td>
                    <select id="selPosition">
                    </select>
                    <input id="iptPosition" class="none" type="text" />
                    <span>*</span>
                </td>
            </tr>
            <tr>
                <td>
                    邮箱：
                </td>
                <td>
                    <input id="email" name="email" type="text" /><span>*</span>
                </td>
                <td>
                    入职时间
                </td>
                <td>
                    <input id="iptStartDate" type="text" />
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td style="text-align: right;">
                    <input class="loginBtn" type="button" id="btnSubmit" value="确定" />
                </td>
                <td style="text-align: center;">
                    <input class="loginBtn" type="reset" id="btnReset" value="清空" />
                </td>
                <td>
                </td>
            </tr>
        </table>
    </div>
    <div class="hiddenAsset none">
        <h2>
        </h2>
        <table id="popupwindow_asset">
            <tr>
                <td>
                    资产编号：
                </td>
                <td>
                    <select id="selAssetID">
                    </select><span> *</span>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td style="text-align: right;">
                    <input type="button" id="btnSubmit_Asset" value="添加" />
                </td>
                <td style="text-align: center;">
                    <input type="button" class="btnSkip" name="asset" value="跳过" />
                </td>
                <td>
                </td>
            </tr>
        </table>
    </div>
    <div class="hiddenAccount none">
        <h2>
        </h2>
        <table>
            <tr>
                <td>
                    Bell账号：
                </td>
                <td>
                    <input id="accountID" type="text" /><span> *</span>
                </td>
                <td>
                    Bell工号：
                </td>
                <td>
                    <input id="employeeID" type="text" /><span> *</span>
                </td>
            </tr>
            <tr>
                <td>
                    账号域名
                </td>
                <td>
                    <input id="accountDomain" type="text" />
                </td>
                <td>
                    账号状态：
                </td>
                <td>
                    <select id="accountStatus">
                        <option value="1">正常状态</option>
                        <option value="2">两周内过期</option>
                        <option value="3">已经过期</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    最近更新时间：
                </td>
                <td>
                    <input id="latestModify" type="text" />
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td style="text-align: right;">
                    <input type="button" id="btnSubmit_cardInBell" value="添加" />
                </td>
                <td style="text-align: center;">
                    <input type="button" class="btnSkip" name="account" value="跳过" />
                </td>
                <td>
                </td>
            </tr>
        </table>
    </div>
    <div class="hiddenCard none">
        <h2>
        </h2>
        <table>
            <tr>
                <td>
                    卡号：
                </td>
                <td>
                    <input id="cardNo" type="text" /><span> *</span>
                </td>
                <td>
                    卡状态：
                </td>
                <td>
                    <select id="cardstatus">
                        <option value="1">正常</option>
                        <option value="2">两周内过期</option>
                        <option value="3">已过期</option>
                    </select>
                    <span>*</span>
                </td>
            </tr>
            <tr>
                <td>
                    最近更新时间：
                </td>
                <td>
                    <input id="cardlatestUpdateDate" name="cardlatestUpdateDate" type="text" />
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td style="text-align: right;">
                    <input type="button" id="btnSubmit_Card" value="完成" />
                </td>
                <td style="text-align: center;">
                    <input type="button" class="btnSkip" name="card" value="跳过" />
                </td>
                <td>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
